package com.huifaapp.mall.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.huifaapp.mall.R;
import com.huifaapp.mall.bean.Tmall_PreDetailBean;
import com.huifaapp.mall.view.NumberSelectView;

import java.util.List;

/**
 * Created by duanyu on 2018/1/2.
 */

public class TmallShopkeerDetailAdapter extends  RecyclerView.Adapter<TmallShopkeerDetailAdapter.MyViewHolder> implements View.OnClickListener{
    private List<Tmall_PreDetailBean.DataBean.ListBean>ccclist;
    private Context Context;

    public TmallShopkeerDetailAdapter(List<Tmall_PreDetailBean.DataBean.ListBean> ccclist, android.content.Context context) {
        this.ccclist = ccclist;
        Context = context;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View recyclerViewItem = LayoutInflater.from(parent.getContext()).inflate(R.layout.itme_tmallshopkeerdetail, parent, false);
        recyclerViewItem.setOnClickListener(this);
        return new MyViewHolder(recyclerViewItem);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.itemView.setTag(position);
        holder.itme_tmallshopkeerdetailorder_orderNo.setText(ccclist.get(position).getOrderNo());
        holder.itme_tmallshopkeerdetailorder_orderTime.setText(ccclist.get(position).getOrderTime());
        holder.itme_tmallshopkeerdetailorder_preIncomename.setText(ccclist.get(position).getPreIncomename());
        holder.itme_tmallshopkeerdetailorder_userNickName.setText(ccclist.get(position).getUserNickName());
        holder.itme_tmallshopkeerdetailorder_actualPay.setText(ccclist.get(position).getActualPay()+"");
        holder.itme_tmallshopkeerdetailorder_profitAmount.setText(ccclist.get(position).getProfitAmount()+"");
        holder.tv_shopkeerdetails_name.setText(ccclist.get(position).getGoodsName());
    }

    @Override
    public int getItemCount() {
        return ccclist.size();
    }
    public interface detailaItemclickListener {
        void detailaitemclick(View view, int position);
    }
    public detailaItemclickListener mMyViewHolderItemclickListener;
    public void setmdetailaItemclickListener(detailaItemclickListener mMyViewHolderItemclickListener) {
        this.mMyViewHolderItemclickListener = mMyViewHolderItemclickListener;
    }
    public void onClick(View v) {
        if (mMyViewHolderItemclickListener != null) {
            mMyViewHolderItemclickListener.detailaitemclick(v, (Integer) v.getTag());
        }

    }

    class MyViewHolder extends RecyclerView.ViewHolder {


        private final TextView itme_tmallshopkeerdetailorder_orderNo;
        private final TextView itme_tmallshopkeerdetailorder_orderTime;
        private final TextView itme_tmallshopkeerdetailorder_preIncomename;
        private final TextView itme_tmallshopkeerdetailorder_userNickName;
        private final TextView itme_tmallshopkeerdetailorder_actualPay;
        private final TextView itme_tmallshopkeerdetailorder_profitAmount;
        private final TextView tv_shopkeerdetails_name;

        public MyViewHolder(View itemView) {
            super(itemView);
            itme_tmallshopkeerdetailorder_orderNo = (TextView) itemView.findViewById(R.id.itme_tmallshopkeerdetailorder_orderNo);
            itme_tmallshopkeerdetailorder_orderTime = (TextView) itemView.findViewById(R.id.itme_tmallshopkeerdetailorder_orderTime);
            itme_tmallshopkeerdetailorder_preIncomename = (TextView) itemView.findViewById(R.id.itme_tmallshopkeerdetailorder_preIncomename);
            itme_tmallshopkeerdetailorder_userNickName = (TextView) itemView.findViewById(R.id.itme_tmallshopkeerdetailorder_userNickName);
            itme_tmallshopkeerdetailorder_actualPay = (TextView) itemView.findViewById(R.id.itme_tmallshopkeerdetailorder_actualPay);
            itme_tmallshopkeerdetailorder_profitAmount = (TextView) itemView.findViewById(R.id.itme_tmallshopkeerdetailorder_profitAmount);
            tv_shopkeerdetails_name= (TextView) itemView.findViewById(R.id.tv_shopkeerdetails_name);
        }



    }
}
